import { createRouter, createWebHistory } from 'vue-router'

const Layout = () => import('@/views/Layout.vue')
const Home = () => import('@/views/home/index.vue')
const TopCategory = ()=>import('@/views/category/index.vue')
const SubCategory = ()=>import('@/views/category/sub.vue')
const Goods = ()=>import('@/views/goods/index.vue')
const Login = () =>import('@/views/login/index.vue')
const TestPage = ()=>import('@/views/test/index.vue')
const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      { path: '/', component: Home },
      { path: '/category/:id', component: TopCategory },
      { path: '/category/sub/:id', component: SubCategory },
      { path: '/product/:id', component: Goods },
    ]
  },
  { path: '/test', component: TestPage },
  { path: '/login', component: Login },
]
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes,
  scrollBehavior () {
    return { left: 0, top: 0 }
  }
})

export default router
